﻿<?php 
/**
 * TomatoCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version 	$Id: _uploader.phtml 4657 2010-08-15 18:12:37Z huuphuoc $
 * @since		2.0.0
 */
?>
<?php
$this->headLink()->appendStylesheet($this->APP_STATIC_SERVER . '/js/jquery.uploadify/uploadify.css');

$this->headScript()
	->appendFile($this->APP_STATIC_SERVER . '/js/jquery.uploadify/jquery.uploadify.min.js')
	->appendFile($this->APP_STATIC_SERVER . '/js/swfobject/swfobject.js');
?>

<input id="<?php echo $this->uploadElementId; ?>" name="uploadFile" type="file" />
<script type="text/javascript">
$(document).ready(function() {
	
	$('#<?php echo $this->uploadElementId; ?>').uploadify({
		'scriptData': { 
			mod: "<?php echo $this->escape($this->module); ?>", 
			PHPSESSID: "<?php echo $this->escape($this->sessionId); ?>"
			<?php if (isset($this->options['thumbnails'])) : ?>, 
			thumbnails: "<?php echo $this->options['thumbnails']; ?>"
			<?php endif; ?> 
		},
		'uploader': '<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.uploadify/uploadify.swf',
		'script': '<?php echo $this->url(array(), 'upload_file_upload'); ?>',
		'cancelImg': '<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.uploadify/cancel.png',
		'buttonImg': '<?php echo $this->APP_STATIC_SERVER; ?>/js/jquery.uploadify/images/browser_<?php echo $this->lang;?>.png',
		'auto': <?php if (isset($this->options['auto']) && ($this->options['auto'] == true)) : ?>true<?php else : ?>false<?php endif; ?>,
		'multi': <?php if (isset($this->options['multi']) && ($this->options['multi'] == true)) : ?>true<?php else : ?>false<?php endif; ?>,
		'fileDesc': <?php if (isset($this->options['extension'])) : echo("'".$this->options['extension']."'");?><?php else : ?>''<?php endif; ?>,
		'fileExt': <?php if (isset($this->options['extension'])) : echo("'".$this->options['extension']."'");?><?php else : ?>''<?php endif; ?>,
		onError: function(event, ID, fileObj, errorObj) {
			<?php if (isset($this->handlers['onError'])) : ?>
			<?php echo $this->handlers['onError']; ?>(event, ID, fileObj, errorObj);
			<?php endif; ?> 
		}, 
		onCancel: function(event, ID, fileObj, data, clearFast) {
			<?php if (isset($this->handlers['onCancel'])) : ?> 
			<?php echo $this->handlers['onCancel']; ?>(event, ID, fileObj, data, clearFast);
			<?php endif; ?> 
		}, 
		onClearQueue: function() {
			<?php if (isset($this->handlers['onClearQueue'])) : ?>
			<?php echo $this->handlers['onClearQueue']; ?>();
			<?php endif; ?> 
		},
		onProgress: function(event, ID, fileObj, data) {
			<?php if (isset($this->handlers['onProgress'])) : ?>
			<?php echo $this->handlers['onProgress']; ?>(event, ID, fileObj, data);
			<?php endif; ?> 
		},
		onComplete: function(event, ID, fileObj, response, data) {
			<?php if (isset($this->handlers['onComplete'])) : ?>
			<?php echo $this->handlers['onComplete']; ?>(event, ID, fileObj, response, data);
			<?php endif; ?> 
		},
		onAllComplete: function(event, uploadObj) {
			<?php if (isset($this->handlers['onAllComplete'])) : ?>
			<?php echo $this->handlers['onAllComplete']; ?>(event, uploadObj);
			<?php endif; ?> 
		}
	});
});
</script>
